/**
 * 功能:随机获得道具 组队道具椅子随机
 * From:芬芬时尚潮流
 */
var status;

//需要的背包空间
var solt = 1;

//显示信息
var message = "";

var RandomItem = Array(
		//道具 - 数量
		Array(3017038, 1), //椅子
		Array(3017037, 1), 
		Array(3017039, 1), 
		Array(3017040, 1), 
		Array(3017041, 1), 
		Array(3017042, 1), 
		Array(3017028, 1), 
		Array(3017029, 1), 	
		Array(3017030, 1), 	
		Array(3017031, 1), 		
		Array(3017032, 1), 	
		Array(3017000, 1), 	
		Array(3017001, 1), 		
		Array(3017002, 1), 
		Array(3017003, 1), 
		Array(3017004, 1), 
		Array(3017005, 1), 
		Array(3017006, 1), 
		Array(3017007, 1), 
		Array(3017008, 1), 
		Array(3017009, 1), 
		Array(3017010, 1), 
		Array(3017017, 1), 
		Array(3017022, 1), 
		Array(3010651, 1), 
		Array(3010652, 1), 
		Array(3010653, 1), 
		Array(3010654, 1), 
		Array(3010655, 1), 
		Array(3010656, 1), 
		Array(3010824, 1), 
		Array(3010825, 1), 
		Array(3010826, 1), 
		Array(3010827, 1), 
		Array(3010829, 1), 
		Array(3010830, 1), 
		Array(3010831, 1), 
		Array(3010832, 1), 
		Array(3010876, 1)
	);

var ItemList = Array();

function start() {
	status = -1;
	item = im.getItemId();
	action(1, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		im.dispose();
	} else {
		if (mode == 0) {
			im.dispose();
			return;
		}
		if (mode == 1) {
			status++;
		} else {
			status--;
		}
		if (status == 0) {
			for (var i = 0; i < RandomItem.length; i++) {
				ItemList.push(RandomItem[i]);
				message += "\r\n#b#i" + RandomItem[i][0] + ":# #t" + RandomItem[i][0] + "#";
                //message += "\r\n打印结果:" + RandomItem[1][0] + "..";				
			}
			im.sendYesNo("您是否要打开 #bPPMS组队任务奖励随机箱（组队通用）#k\r\n#d您将会获得以下其中一个物品：\r\n" + message + "\r\n");
		} else if (status == 1) {
			if (im.getSpace(3) >= solt && im.used()) {
				var random = new java.util.Random();
				var finalchance = random.nextInt(ItemList.length);
				var itemID = ItemList[finalchance][0];
				var count = ItemList[finalchance][1];
				im.gainItem(itemID, count);
			    im.openNpc(9000193,"2431114");				
				im.sendOk("恭喜你从#bPPMS组队任务奖励随机箱里面获得#k :\r\n\r\n#b#i" + itemID + ":# #t" + itemID + "# x " + count + "\r\n\r\n#r请注意查看！ ");
			    im.worldSpouseMessage(0x15, "[组队随机箱（椅子）] : "+ im.getPlayer().getName()+" 从中获得了 ["+ im.getItemName(itemID) + "] x " + count + "运气真的太好啦！");				
				im.dispose();
			} else {
				im.sendOk("您的 #r消耗栏#k 空间没有#r#e " + solt + " #n#k个空位！无法获得 \r\n#b#i" + item + ":# #t" + item + "# #k 里的以下物品:\r\n" + message);
				im.dispose();
			}
		}
	}
}
